<?php
/*
 * File name : Model.php
 * Description : Model.php handles call to the database and returns the fetched vales to the controller.
 * Created By : Pratibha Awasthi.
 */

include_once "basePage.php";

// This class deals with querying the database and returning the vales to the Controller.
class Model extends basePage{
	
	//Prints the current pledges of the sunbscriber 
	public function current_pledges(){
			
		    $con = mysql_connect('localhost','pa_user','secret_password');
			if (!$con){
		  		die('Could not connect: ' . mysql_error());
		  	}
		  
			mysql_select_db("TGS_GM_RESERVATION", $con);
			
			session_start();
			$userid = $_SESSION['userid'];
			
			$result_curr = mysql_query("SELECT * FROM TGS_GM_RESERVATION.tblsubscriberpledge where tblSubscriber_SubscriberID = (SELECT SubscriberID FROM TGS_GM_RESERVATION.tblsubscriber WHERE UserID = '{$userid}')");
			$row_curr = mysql_fetch_array($result_curr);
			
			$result = mysql_query("SELECT * FROM TGS_GM_RESERVATION.tblsubscriberpledge where tblSubscriber_SubscriberID = (SELECT SubscriberID FROM TGS_GM_RESERVATION.tblsubscriber WHERE UserID = '{$userid}')");
			
			// Return multiple values to the Controller.
			return array($result_curr,$row_curr,$result);
	}
}

?>